/* 
This script runs in every page when the extension is installed. It is specific to the extension version of cqstyle.
Other client side functions shared between the desktop version of cqstyle and the extension are stored in cqstyle_client.js
*/
    
function getEval (args) {
    
    console.log(args.code);

    var ret = eval(args.code
        .replace(/\\'/g, "'") // unescape single quotes
        .replace(/\\"/g, '"') // unescape double quotes
    );
    
    console.log('code: ' + args.index);
    
    chrome.extension.sendRequest({type: 'getEval', index: args.index, result: ret, refresh: args.refresh}, function(response) {});
}

$(document).ready(function () {
    chrome.extension.sendRequest({greeting: "refresh"}, function(response) {});
});